package com.baicaoyuan.web.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

@RequiredArgsConstructor
@Getter
public enum BusinessStatusEnum {

    /**
     * 创建
     */
    CREATE("0"),

    /**
     * 锁定
     */
    LOCK("1"),


    /**
     * 上传凭证
     */
    UPLOAD_VOUCHER("2"),
    /**
     * 成交
     */
    DONE("3"),

    /**
     * 取消
     */
    CANCEL("9");

    private final String status;

    /**
     * 根据标识获取枚举
     *
     * @param businessStatus
     * @return
     */
    public static BusinessStatusEnum acquire(final String businessStatus) {
        Optional<BusinessStatusEnum> belongEnum = Arrays.stream(BusinessStatusEnum.values())
                .filter(v -> Objects.equals(v.getStatus(), businessStatus))
                .findFirst();
        return belongEnum.orElse(BusinessStatusEnum.CREATE);
    }

}
